﻿using BUS;
using DAO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CameraProjects
{
    public partial class ChiTiet : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string cate = Request.QueryString["cate"].ToString();
                int id = int.Parse(Request.QueryString["id"].ToString());
                LoadDuLieu(cate, id);
            }
        }

        private void LoadDuLieu(string cate, int id)
        {
            if (cate == "camera")
            {
                // lay danh sach camera
                CameraBUS cB = new CameraBUS();
                ddlMayAnh.DataSource = cB.GetListTop10();
                ddlMayAnh.DataBind();

                // load thong tin
                Camera c = new Camera();
                c = cB.GetById(id);
                lblName.Text = c.camNames;
                lblPrice.Text =  string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("vi-VN"), "{0:#,## VNĐ}",  c.camPrice);
                lblDetails.Text = c.camDetails;

                // load hinh anh
                ImagesCameraBUS iBUS = new ImagesCameraBUS();
                List<ImagesCamera> listimage = new List<ImagesCamera>();
                listimage = iBUS.GetListByCamera(id);
                dtImages.DataSource = listimage;
                dtImages.DataBind();
            }
            else if (cate == "lens")
            {

            }
            else if (cate == "accessories")
            { 
            }
        }
         
    }
}